{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Assignment 10"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 1.复习上课内容"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 贝叶斯分类器\n",
    "- 垃圾邮件的鉴别\n",
    "- 贝叶斯法则公式\n",
    "    $$ P(A|B) = \\frac{P(A|B)}{P(B)} = \\frac{P(B|A)P(A)}{P(B)}$$ \n",
    "- 全概率公式\n",
    "    $$ P(A) = \\sum{P(A|B_i)P(B_i)}$$\n",
    "\n",
    "## K-means\n",
    "- 无监督聚类\n",
    "- 开始先随机选取K个类别，然后计算其他每个点到这K个点的距离，把近的点归为一类，然后重新计算这K个类别点中心点。然后反复重复上述操作，直至上述点不再更新\n",
    "\n",
    "\n",
    "## SVM\n",
    "- 数学\n",
    "- 是一种二分类模型，基本模型是定义在特征空间上的间隔最大的线性分类器，其基本想法是求解能够正确划分训练数据集并且几何间隔最大的分离超平面。\n",
    "\n",
    "\n",
    "# Ensemble learning 集成学习\n",
    "\n",
    "\n",
    "## 随机森林\n",
    "\n",
    "## XGboost"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 2. 回答一下理论题目"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 1. What is independent assumption in Naive bayes ?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "假设事件发生的概率之间是相互独立的 ；朴素：独立假设 "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 2. What is MAP(maximum a posterior) and ML(maximum likelihood) ?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**MAP:** 最大化后验概率，在给定一系列数据时，从这些数据中选择出最有可能的数据。\n",
    "\n",
    "h: hypothesis space{f},所有可能的函数,每个函数对应一个预测值，如果f是线性的，则该含义就是从所有线性函数中选择一条线性函数出来。\n",
    "D:数据集,因为数据集是固定的，所以P(D)是一个常数，分母可以去掉。\n",
    "$$h_{MAP} = argmaxP(h|D)=argmax\\frac{P(D|h)P(h)}{P(D)}=argmaxP(D|h)P(h)$$\n",
    "\n",
    "**ML：** 最大化期望值\n",
    "p(h)是指函数发生可能的假设概率。如果P(h)是一个常数，就是指h是一样的，没有任何偏好，无差别的，这是就可以进一步化简上面的公式，这就是最大化期望值\n",
    "$$h_{ML} = argmaxP(D|h)P(h)$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 3. What is support vector in SVM?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- 支持向量是指虚线边界上的点\n",
    "- 距离超平面最近的点称为支持向量"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 4. What is the intuition behind SVM ?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- 使所有点之间间距最大化"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 5. Shortly describ what 'random' means in random forest ?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 6. What cariterion does XGBoost use to find the best split point in a tree ?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 3. Practial part"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### Problem description: In this part you are going to build a classifier to detect if a piece of news is published by the Xinhua news agency (新华社）."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Hints:"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###### 1. Firstly, you have to come up with a way to represent the news. (Vectorize the sentence, you can find different ways to do so online)  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###### 2. Secondly,  pick a machine learning algorithm that you think is suitable for this task"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Congratulations! You have completed all assignments in this week. The question below is optional. If you still have time, why don't try it out."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Option:"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Try differnt machine learning algorithms with different combinations of parameters in the practical part, and compare their performances (Better use some visualization techiniques)."
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
